package com.nyist.controller;

import com.nyist.pojo.User;
import com.nyist.result.CommonResult;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
public class ProviderController8002 {

    @Value("${server.port}")
    private String port;

    @GetMapping(value = "/provider/hello/{name}")
    public CommonResult hello(@PathVariable("name") String name){
        User user = new User(11,name,18);
        System.out.println("进入提供者：进行提供服务");
        return new CommonResult("200","success port:"+port,user);
    }


    @GetMapping(value = "/provider/loadbalancer/lb")
    public String getLbPort(){
        return port;
    }

    @GetMapping(value = "/provider/openfegin/timeout")
    public String getOpenFeginTimeOut(){
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return port;
    }


    @GetMapping(value = "/provider/zipkin")
    public String paymentZipkin(){
        return "Hi ,I AM paymentZipkin "+port;
    }

}
